package com.appservice.controller;

import com.vidyu.businesslayer.businessentities.Employer;
import com.vidyu.servicelayer.servicedataentitties.EmployerRO;
import com.vidyu.servicelayer.serviceinterface.ControllerServiceWrapper;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * Created by IntelliJ IDEA.
 * Session: eyalsa
 * Date: 06/03/12
 * Time: 16:11
 * Link Users To Agency
 */
@Controller
public class EmployerController {

    private static final Logger logger = Logger.getLogger(EmployerController.class);

    @Autowired
    ControllerServiceWrapper controllerServiceWrapperImpl;

    @RequestMapping(value = "/vidyu/employer/create",method = RequestMethod.POST)
    public @ResponseBody
    long addEmployer(@RequestBody EmployerRO employerRO) throws Exception {
        try {
            return controllerServiceWrapperImpl.addEmployer(employerRO);
        } catch (Exception e) {
            logger.fatal(e);
            throw e;
        }
    }

    //GET http://localhost:8081/vidyu/Employer/get/email@test.cossm/password
    @RequestMapping(value = "/vidyu/employer/get/{email}/{password}",method = RequestMethod.GET)
    public @ResponseBody
    Employer getEmployer(@PathVariable String email, @PathVariable String password )throws Exception {
        try {
            return controllerServiceWrapperImpl.getEmployerByEmailAndPassword(email, password);
            } catch (Exception e) {
            logger.fatal(e);
            throw e;
        }
    }
}

